<h1>Санал асуулга</h1>

<?php echo link_to('жагсаалт', 'poll/index', array('class'=>'title'))?> 
<span class="separator"> | </span>
<?php echo link_to('шинээр нэмэх', 'poll/new', array('class'=>'title'))?>
<br clear="all">
<br clear="all">

<form action="<?php echo url_for('poll/index')?>" method="GET">
    <fieldset>
        <legend>Хайлт / Шүүлт</legend>
        <select id="league_id" name="league_id" style="width:385px;">
          <?php $leagues = Doctrine::getTable('BbLeague')->fetcharray();?>
          <?php foreach ($leagues as $key=>$value):?>
              <option <?php if ($sf_params->get('league_id') == $key) echo 'selected';?> value="<?php echo $key?>"><?php echo $value?></option>
          <?php endforeach?>
        </select>
        <input type="submit" value="Харуулах" />
    </fieldset>
</form>

<br clear="all">


<table width="100%">
	<thead>
		<tr>
		  <th>№</th>
		  <th>Лиг</th>
		  <th>Санал асуулга</th>
		  <th>Сонголтууд</th>
		  <th>Эрэмбэ</th>
		  <th>Үүсгэсэн огноо</th>
	    <th>#</th>
		</tr>
	</thead>
	<tbody>
	  <?php $i=0; foreach ($pager->getResults() as $poll): ?>
  	<tr <?php if(!$poll->getIsActive()) echo 'style="background:#eee;"' ?>>
  	  <td><?php echo ++$i?></td>
  	  <td><?php echo $poll->getBbLeague()?></td>
      <td><?php echo $poll?></td>
      <td><?php echo $poll->getOptions()?></td>
      <td><?php echo $poll->getSort()?></td>
      <td><?php echo $poll->getCreatedAt() ?></td>
      <td nowrap>
          <a href="<?php echo url_for('poll/optionNew?poll_id='.$poll->getId()) ?>">Сонголтууд</a> <br><br>
          <?php
            if($poll->getIsActive()) echo link_to('Идэвхигүй болгох', 'poll/activate?a=0&id='.$poll->getId(), array());
            else echo link_to('Идэвхижүүлэх', 'poll/activate?a=1&id='.$poll->getId(), array());
          ?> <br><br>
          <a href="<?php echo url_for('poll/edit?id='.$poll->getId()) ?>">Засварлах</a> <br><br>
          <a onclick="confirm('Та итгэлтэй байна уу?')" href="<?php echo url_for('poll/delete?id='.$poll->getId()) ?>">Устгах</a>
      </td>
    </tr>
    <?php endforeach; ?>
	</tbody>
</table>
<?php echo pager($pager, 'poll/index')?>